package com.jie.scrollviewwithlistview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

/**
 * Created by Administrator on 2017/4/19.
 */

public class MyAdapter extends BaseAdapter {
    private List<String> datas;
    private Context context;

    public MyAdapter(List<String> datas, Context context) {
        this.datas = datas;
        this.context = context;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_view, parent, false);
        TextView textView = (TextView) view.findViewById(R.id.item_tv);
        textView.setText(datas.get(position));
        return view;
    }
}
